/*kZime*/
#include <iostream>
#include <cstdio>
using namespace std;

int u[233], n, m, ans;
bool f[233];

inline int read() {
	int k = 0; char c = getchar();
	for(; !isdigit(c); c = getchar());
	for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
	return k;
}

int getf(int i) {
	if(u[i] == i) {
		return i;
	}
	else {
		u[i] = getf(u[i]);
		return u[i];
	}
}

int main() {
	n = read();
	for(int i = 1; i <= n; i++)u[i] = i;
	for(int i = 1; i <= n; i++) {
		int y = i;
		int yf = getf(y); 
		while(true) {
			int x = read();
			if(!x) break;
			else {
				int xf = getf(x);
				u[xf] = yf;
			}
		}
	}
	
	for(int i = 1; i <= n; i++) {
		if(!f[u[i]]){
			ans++;
			f[u[i]] = 1;
		}
	}
	
	printf("%d",ans);
}
